package com.jt.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.core.userdetails.User;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {
    /**
     * 根据用户名查询用户信息
     * @param username
     * @return
     */
    @Select("select * from sys_user where username = #{username}")
    Map<String,Object> userNameSelect(@Param("username") String username);

    /**
     * 根据用户id查询用户权限信息
     * @param id
     * @return
     */
    @Select(" select distinct m.permission " +
            " from sys_user u left join sys_user_role ur on u.id=ur.user_id " +
            " left join sys_role_menu rm on ur.role_id=rm.role_id " +
            " left join sys_menu m on rm.menu_id=m.id " +
            " where u.id=#{id}")
    List<String> SelectUserPermissions(@Param("id") Long id);
}
